import java.util.Arrays;
public class Main2 {
    public static int pivotIndex(int[] nums) {
        //用到前缀和知识
        int total = Arrays.stream(nums).sum();
        int sum = 0;
        for(int i = 0;i < nums.length;i++) {
            if(2*sum+nums[i] == total) {
                return i;
            }
            sum += nums[i];
        }
        return -1;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3};
        int ret = pivotIndex(nums);
        System.out.println(ret);
    }
}

